/*
 *
 *  * Copyright (c) 2016. For Intelligent Group.
 *
 */

package com.intelligent.ispc.client.event;

import com.google.common.eventbus.Subscribe;
import com.intelligent.ispc.client.core.view.analysis.report.YieldPanel;
import com.intelligent.ispc.client.core.view.analysis.spc.SpcMainPanel;
import com.intelligent.ispc.client.utils.ApplicationBeanUtils;
import com.intelligent.ispc.client.utils.UIConstant;

/**
 * Created by Peter on 2016/9/6.
 */
public class AnalysisFileChangeListener {

    /**
     * Event subscribe method for spc.
     *
     * @param event AnalysisFileChangeEvent instance
     */
    @Subscribe
    public void spcChange(AnalysisFileChangeEvent event) {
        try {
            if (event.getKey().equals(UIConstant.MODULE_SPC)) {
                ApplicationBeanUtils.getBean(SpcMainPanel.class).onFileChange(event.getFiles());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Event subscribe method for yield.
     *
     * @param event AnalysisFileChangeEvent instance
     */
    @Subscribe
    public void yieldChange(AnalysisFileChangeEvent event) {
        try {
            if (event.getKey().equals(UIConstant.MODULE_YIELD)) {
                ApplicationBeanUtils.getBean(YieldPanel.class).onFileChange(event.getFiles());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
